import tushare as ts
import talib
from matplotlib import pyplot as plt

# 通过tushare获取股票信息
df = ts.get_k_data('300580', start='2017-01-12', end='2017-05-26')
# 提取收盘价
closed = df['close'].values

upper, middle, lower = talib.BBANDS(closed, matype=talib.MA_Type.T3)

print(
    upper, middle, lower)
plt.plot(upper)
plt.plot(middle)
plt.plot(lower)
plt.grid()
plt.show()
diff1 = upper - middle
diff2 = middle - lower
print(diff1, diff2)
